package io.filecopy;

import java.io.File;
import java.io.FileFilter;

public class JobDescriptionImpl implements JobDescription {

  private File destDir;
  
  private SynchronizeMode synchronizeMode;

  private DirectoryMode directoryMode;

  private FileFilter filter;

  private LastModifyTimeMode lastModifyTimeMode;

  private transient PreparedJob preparedJob;

  private ReplaceMode replaceMode;

  private File sourceDir;

  public JobDescriptionImpl(File sourceDir, File destDir, FileFilter filter,
      DirectoryMode directoryMode, LastModifyTimeMode lastModifyTimeMode,
      ReplaceMode replaceMode, SynchronizeMode synchronizeMode) {
    this.sourceDir = sourceDir;
    this.destDir = destDir;
    this.filter = filter;
    this.directoryMode = directoryMode;
    this.lastModifyTimeMode = lastModifyTimeMode;
    this.replaceMode = replaceMode;
    this.synchronizeMode = synchronizeMode;
  }
  
  @Override
  public SynchronizeMode getSynchronizeMode() {
    return synchronizeMode;
  }

  @Override
  public File getDestinationDirectory() {
    return destDir;
  }

  @Override
  public DirectoryMode getDirectoryMode() {
    return directoryMode;
  }

  @Override
  public FileFilter getFilter() {
    return filter;
  }

  @Override
  public LastModifyTimeMode getLastModifyTimeMode() {
    return lastModifyTimeMode;
  }

  @Override
  public ReplaceMode getReplaceMode() {
    return replaceMode;
  }

  @Override
  public File getSourceDirectory() {
    return sourceDir;
  }

  @Override
  public synchronized PreparedJob prepare(JobPreparationListener listener) {
    if (preparedJob == null) {
      preparedJob = new PreparedJobImpl(this, listener);
    }
    return preparedJob;
  }
  
  @Override
  public String toString() {
    return "JobDescription[src=\"" + sourceDir.getAbsolutePath() + "\", dst=\"" + destDir.getAbsolutePath() + "\", " + directoryMode + ", " + lastModifyTimeMode + ", " + replaceMode + ", " + synchronizeMode + "]";
  }
}